/**
 * 
 */
package utils.orm.jpa;

import java.util.List;

import javax.persistence.Query;

import utils.orm.jpa.PropertyFilter.MatchType;

/**
 * @author ice
 *
 */
public class JPAPropertyFilterUtil {
	public static void setParameter(Query query,List<PropertyFilter> propertyFilterList){
		if(propertyFilterList!=null){
			for (PropertyFilter propertyFilter : propertyFilterList) {
				for (int i = 0; i < propertyFilter.getPropertyFullNames().length; i++) {
					if(propertyFilter.getMatchType()!=MatchType.IN){
						String propertyFullName = propertyFilter.getPropertyFullNames()[i];
						query.setParameter(propertyFullName.replace('!', '_').replace('.','_')+propertyFilter.getOrdernos()[i], propertyFilter.getMatchValue());
					}
				}
			}
		}
	}

}
